//
//  NString.swift
//  Split
//
//  Created by shenboren on 2017/9/20.
//  Copyright © 2017年 shenboren. All rights reserved.
//

import Foundation

extension NSString {

    func split(splitStr:NSString) -> [NSString] {
        
        var lastStr = self
        var res: [NSString] = []
        for _ in 0..<self.length{
            let strRange = lastStr.range(of: splitStr as String)
            if strRange.length != 0{
                let subStr = lastStr.substring(to: strRange.location)
                res.append(subStr as NSString)
                lastStr = lastStr.substring(from: strRange.location + splitStr.length) as NSString
            }else{
                res.append(lastStr)
                return NullValue(str: res)
            }
        }
        return []
    }
        func NullValue(str:[NSString]) -> [NSString]{
            var res:[NSString] = []
            for i in 0..<str.count{
                if str[i] != ""{
                    res.append(str[i])
                }
            }
            return res
        }
}
